package com.lovo.stock.controller;

import com.lovo.stock.bean.ContentBean;
import com.lovo.stock.constant.MessageCode;
import com.lovo.stock.service.IContentService;
import com.lovo.stock.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 常量控制器
 */
@RestController
@RequestMapping("/content")
public class ContentController {

    @Autowired
    IContentService contentService;

    @RequestMapping("/queryContentByType")
    public ResponseResult<List<ContentBean>> queryContentByType(int type){
        ResponseResult<List<ContentBean>> responseResult=new ResponseResult<>();
        try {
            responseResult.setData(contentService.queryContentByType(type));
        }catch (Exception e){
            e.printStackTrace();
            responseResult.setMessage(MessageCode.ERROR.message);
            responseResult.setCode(MessageCode.ERROR.code);
        }
        return responseResult;
    }
}
